#ifndef __WEB_PAGE_SEARCH_H__ 
#define __WEB_PAGE_SEARCH_H__ 

#include "WebPage.h" 
#include "SplitTool.h"
#include <iostream>
#include <map>
#include <string>
#include <unordered_map>
#include <vector>

using std::vector;
using std::map;
using std::unordered_multimap;
using std::pair;
using std::string;
using std::cout;
using std::endl;

class WebPageQuery{
public:
    WebPageQuery(){
        iniSearchCon();
    };

    ~WebPageQuery(){};
    vector<WebPage> doQuery(string key);
    void iniSearchCon();
    void readPages(); 
    void readInvert();
    void readOffset();
    void icuFix(string shortdes, WebPage &web);
    void getWebPageCon(WebPage &web, WebPage &webc,char buff[]);
    double calCosSimilarity(const vector<double>& vec1, const vector<double>& vec2);
    double calMagnitude(const vector<double>& vec); 
    vector<int> similaritySort(map<int, pair<int, vector<double>>> &countMap, int width);

private:
    vector<WebPage> _pages;
    vector<WebPage> _pagesCpe;
    map<int, pair<int, int>> _offsetlib;
    unordered_multimap<string, pair<int, double>> _invertIndexLib;
    SplitTool _wordCutTool;
};

#endif // !__WEB_PAGE_Search_ 
